/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.openams.server.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author mike
 */
@Entity
@Table(name = "discreteassets")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DiscreteAsset.findAll", query = "SELECT d FROM DiscreteAsset d"),
    @NamedQuery(name = "DiscreteAsset.findByDiscreteAssetID", query = "SELECT d FROM DiscreteAsset d WHERE d.discreteAssetID = :discreteAssetID"),
    @NamedQuery(name = "DiscreteAsset.findByAssetName", query = "SELECT d FROM DiscreteAsset d WHERE d.assetName = :assetName")})
public class DiscreteAsset implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "DiscreteAssetID", nullable = false)
    private Integer discreteAssetID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 256)
    @Column(name = "AssetName", nullable = false, length = 256)
    private String assetName;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Column(name = "Point", nullable = false)
    private byte[] point;
    @OneToMany(mappedBy = "discreteAssetID", fetch = FetchType.LAZY)
    private Collection<DiscretAssetAssignment> discretAssetAssignmentCollection;
    @JoinColumn(name = "AssetCategoryID", referencedColumnName = "AssetCategoryID", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private AssetCategory assetCategoryID;

    public DiscreteAsset() {
    }

    public DiscreteAsset(Integer discreteAssetID) {
        this.discreteAssetID = discreteAssetID;
    }

    public DiscreteAsset(Integer discreteAssetID, String assetName, byte[] point) {
        this.discreteAssetID = discreteAssetID;
        this.assetName = assetName;
        this.point = point;
    }

    public Integer getDiscreteAssetID() {
        return discreteAssetID;
    }

    public void setDiscreteAssetID(Integer discreteAssetID) {
        this.discreteAssetID = discreteAssetID;
    }

    public String getAssetName() {
        return assetName;
    }

    public void setAssetName(String assetName) {
        this.assetName = assetName;
    }

    public byte[] getPoint() {
        return point;
    }

    public void setPoint(byte[] point) {
        this.point = point;
    }

    @XmlTransient
    public Collection<DiscretAssetAssignment> getDiscretAssetAssignmentCollection() {
        return discretAssetAssignmentCollection;
    }

    public void setDiscretAssetAssignmentCollection(Collection<DiscretAssetAssignment> discretAssetAssignmentCollection) {
        this.discretAssetAssignmentCollection = discretAssetAssignmentCollection;
    }

    public AssetCategory getAssetCategoryID() {
        return assetCategoryID;
    }

    public void setAssetCategoryID(AssetCategory assetCategoryID) {
        this.assetCategoryID = assetCategoryID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (discreteAssetID != null ? discreteAssetID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DiscreteAsset)) {
            return false;
        }
        DiscreteAsset other = (DiscreteAsset) object;
        if ((this.discreteAssetID == null && other.discreteAssetID != null) || (this.discreteAssetID != null && !this.discreteAssetID.equals(other.discreteAssetID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.openams.server.entity.DiscreteAsset[ discreteAssetID=" + discreteAssetID + " ]";
    }
    
}
